//	This document define the datasource api.
dojo.provide("spaghetti.datasource");

dojo.require("spaghetti.utility");

dojo.declare("spaghetti.datasource.query.api", null, {
	//	summary:
	//		This will define the query api.
	
	query : function(/*Object*/ query, /*Object*/ keywordArgs){
		//	summary:
		//		This is the function for the query. It will take an object for query. Different implementations
		//		may have different query structure. It is the datasource's task to cache the query result. So the
		//		query should not have any result cache settings.
		//
		//	query: Object
		//		The query object. The object below is an example for a query object.
		//		|	{
		//		|		type : "employee",
		//		|		criteria : { age : 26, gender : 'male' },
		//		|		condition : "name like 'Ja%' or name like 'Ro%'",
		//		|		range : { begin : 20, count : 50 },
		//		|		sort : { orderBy : "id", ascendant : true }
		//		|	}
		//		or if the query implementation support sql, this query is the same
		//		|	{
		//		|		sql : "select * from employee where age = 26 and gender = 'male' and (name like 'Ja%' or
		//		|			name like 'Ro%') and rownum > 20 and rownum <= 70 order by id asc"
		//		|	}
		//
		//		Suggest implement all of above, :)
		//
		//	keywordArgs: Object
		//		The callback configration for this query operation. It can have 3 callbacks.
		//		*onBegin* this callback will be called when the query begins. Mostly the query will be post to the
		//		server. Before post it to the server, the callback will be called by the query object. Can modify 
		//		the query object to add some more condition for some reason(for example, result filter).
		//
		//		*onComplete* this callback will be called when the server answered back. This callback will be called
		//		by the dataset as the argument. All the message may be access by the dataset meta data. The datasource
		//		support that.
		//
		//		*onError* this callback will be called when an error comes, the callback will be called by 2 arguments.
		//		The query object, and an error message. The error message should be like this
		//		|	{ code : 404, message : "The resource requested is not found." }
		
		spaghetti.notImplement("query");
	}
});

dojo.declare("spaghetti.datasource.persist.api", null, {
	//	summary:
	//		This will define the data persist api.
	
	save : function(/*Dataset*/ dataset, /*Object*/ keywordArgs){
		//	summary:
		//		This is the persist function. It will persist the dataset to the server.
	}
});

dojo.declare("spaghetti.datasource.processing.api", null, {
	//	summary:
	//		This will define the data processing api.
});

dojo.declare("spaghetti.datasource.provider.api", null, {
	//	summary:
	//		This will define the data provider api.
});

dojo.declare("spaghetti.datasource.DataSource", null, {
	//	summary:
	//		This will define the datasource api.
});